package com.hhdys.message;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class OABody extends MessageBody {
	/**
	 * 客户端点击跳转的url
	 */
	private String message_url;
	/**
	 * PC端点击消息时跳转到的H5地址
	 */
	private String pc_message_url;
	/**
	 * 消息头部内容
	 */
	private Head head;
	
	
	public class Head{
		/**
		 * 消息头部的背景颜色。长度限制为8个英文字符，其中前2为表示透明度，后6位表示颜色值。不要添加0x
		 */
		private String bgcolor;
		/**
		 * 消息的头部标题（仅适用于发送普通场景）
		 */
		private String text;
		
		public String getBgcolor() {
			return bgcolor;
		}

		public void setBgcolor(String bgcolor) {
			this.bgcolor = bgcolor;
		}

		public String getText() {
			return text;
		}

		public void setText(String text) {
			this.text = text;
		}

		public Head(String bgcolor, String text) {
			super();
			this.bgcolor = bgcolor;
			this.text = text;
		}
		
	}
	
	public Head createHead(String bgcolor,String text){
		return new Head(bgcolor,text);
	}
	/**
	 * 消息体
	 */
	private Body body;
	
	public class Body{
		/**
		 * 消息体的标题
		 */
		private String title;
		/**
		 * 消息体的表单，最多显示6个，超过会被隐藏
		 *  key:消息体的关键字
		 *  value:消息体的关键字对应的值
		 */
		private List<Form> form;
		/**
		 * 单行富文本信息
		 */
		private String content;
		/**
		 * 消息体中的图片media_id
		 */
		private String image;
		/**
		 * 自定义的附件数目。此数字仅供显示，钉钉不作验证
		 */
		private String file_count;
		/**
		 * 	自定义的作者名字
		 */
		private String author;
		/**
		 * 单行富文本信息
		 */
		private Rich rich;
		
		public class Rich{
			/**
			 * 单行富文本信息的数目
			 */
			private String num;
			/**
			 * 单行富文本信息的单位
			 */
			private String unit;
			public String getNum() {
				return num;
			}
			public void setNum(String num) {
				this.num = num;
			}
			public String getUnit() {
				return unit;
			}
			public void setUnit(String unit) {
				this.unit = unit;
			}
			public Rich(String num, String unit) {
				super();
				this.num = num;
				this.unit = unit;
			}
			
		}
		
		public class Form{
			private String key;
			private String value;
			public String getKey() {
				return key;
			}
			public void setKey(String key) {
				this.key = key;
			}
			
			public String getValue() {
				return value;
			}
			public void setValue(String value) {
				this.value = value;
			}
			public Form(String key, String val) {
				super();
				this.key = key;
				this.value = val;
			}
			
		}
		
		public List<Form> createFormList(Map<String, String> map){
			if(map.entrySet().isEmpty()){
				return null;
			}
			List<Form> list=new ArrayList<Form>();
			for(Map.Entry<String, String> item:map.entrySet()){
				Form form=new Form(item.getKey(), item.getValue());
				list.add(form);
			}
			return list;
		}
		public Rich createRich(String num,String unit){
			return new Rich(num, unit);
		}
		public String getTitle() {
			return title;
		}
		public void setTitle(String title) {
			this.title = title;
		}
		
		public List<Form> getForm() {
			return form;
		}
		public void setForm(List<Form> form) {
			this.form = form;
		}
		public String getContent() {
			return content;
		}
		public void setContent(String content) {
			this.content = content;
		}
		public String getImage() {
			return image;
		}
		public void setImage(String image) {
			this.image = image;
		}
		public String getFile_count() {
			return file_count;
		}
		public void setFile_count(String file_count) {
			this.file_count = file_count;
		}
		public String getAuthor() {
			return author;
		}
		public void setAuthor(String author) {
			this.author = author;
		}
		public Rich getRich() {
			return rich;
		}
		public void setRich(Rich rich) {
			this.rich = rich;
		}
		
	}
	
	public Body createBody(){
		return new Body();
	}

	public String getMessage_url() {
		return message_url;
	}

	public void setMessage_url(String message_url) {
		this.message_url = message_url;
	}

	public String getPc_message_url() {
		return pc_message_url;
	}

	public void setPc_message_url(String pc_message_url) {
		this.pc_message_url = pc_message_url;
	}

	public Head getHead() {
		return head;
	}

	public void setHead(Head head) {
		this.head = head;
	}

	public Body getBody() {
		return body;
	}

	public void setBody(Body body) {
		this.body = body;
	}
	

}
